package priv.pront.code.lanqiao.competition.course.date0327;

public class Test {

    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        int num = 6;
        int left = 0;
        int right = arr.length - 1;
        while (left <= right) {
            int mid = left + (right - left) / 2;
            if(arr[mid] > num){
                right = mid - 1;
            }else if(arr[mid] < num){
                left = mid + 1;
            } else if (arr[mid] == num) {
                System.out.println(mid);
                return;
            }
        }
        System.out.println("未找到！");
    }
}
